package com.tangcco.controller;

import com.tangcco.biz.MusicBiz;
import com.tangcco.pojo.Music;
import com.tangcco.pojo.Page;
import com.tangcco.utils.PageUtil;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/music")
public class MusicController {
	@Resource
	private MusicBiz musicBiz;

	@RequestMapping("/selectBySingerId")
	public String selectBySingerId(String sId,Integer currentPage, Model model){
		Integer everyPage = 15;
		Integer totalCount = musicBiz.selectCountBySingerId(sId);
		Page page = PageUtil.createPage(everyPage,totalCount,currentPage);
		List<Music> musicList = musicBiz.selectBySingerId(sId,page);
		if(musicList.size() > 0){
			model.addAttribute("page",page);
			model.addAttribute("musicList",musicList);
			return "musicList";
		}
		return null;
	}

}
